package com.girl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class TransService {
    @Autowired
    private GirlRepository girlRepository;
    @Transactional //加上这个就代表是一个事物,数据库中的字段为1，但是bb是两个，发生异常，事物失败
    public void insertTwo(){
       Girl girl = new Girl();
       girl.setAge(2);
       girl.setCupSize("a");
       girlRepository.save(girl);

        Girl girl2 = new Girl();
        girl.setAge(3);
        girl.setCupSize("bb");
        girlRepository.save(girl2);
    }
}
